<?php
/**
 * Created by PhpStorm.
 * User: lullabies
 * Date: 2019/5/21
 * Time: 16:16
 */

namespace app\api\model;


use think\Model;

class Captcha extends Model
{
    /**
     * 将验证码数据表与用户表进行一对一关联
     */
    public function user(){
        return $this->belongsTo('user','phone','phone');
    }
    /**
     * 根据手机号 查找验证码相关信息
     */
    public static function  getInfoByPhone($phone){
        // 使用查询构造器查询满足条件的数据
        //$result = self::where('phone','=',$phone)->find();
        //动态查询
        $result = self::getByPhone($phone);
        return $result;
    }
    /**
     * 根据手机号 查找相关信息
     */
    public static function getUserInfoByPhone($phone){
        $result = self::with('user')->getByPhone($phone);
        return $result;
    }
}